package com.bigdata.exam

import org.apache.spark.{SparkConf, SparkContext}

object Gaokao {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setMaster("local")
    conf.setAppName("accumulator")
    val sc = new SparkContext(conf)
    sc.setLogLevel("error")
    //读取文件
    val input = sc.textFile("/data/examination2019.csv")

    //查找出各地区本科批次的分数线
    val score = input.map(x => {
      val line = x.split(",")
      (line(0), line(1), line(2), line(3))
    }).filter(_._3.contains("本科批"))

    //将结果以文本格式存储到HDFS上
    score.saveAsTextFile("/data/examination2019")
  }
}
